# page/page_personal_center.py
import time
import random
from base.base import Base
from loc.personal_center_page_locators import PersonalCenterPageLocators

class PagePersonalCenter(Base):
    def navigate_to_bank_cards(self):
        """导航到银行卡管理页面"""
        self.click(PersonalCenterPageLocators.SUB_MENU_BANK_CARDS)
        time.sleep(1)
        return self

    def add_bank_card(self, bank_name, card_number):
        """添加银行卡"""
        self.click(PersonalCenterPageLocators.ADD_BANK_CARD_MODAL_BUTTON)
        time.sleep(1)
        self.input_text(PersonalCenterPageLocators.BANK_NAME_INPUT, bank_name)
        self.input_text(PersonalCenterPageLocators.CARD_NUMBER_INPUT, card_number)
        self.click(PersonalCenterPageLocators.SAVE_BANK_CARD_BUTTON)
        time.sleep(1)
        return self

    def get_latest_card_number(self):
        """获取列表中最新添加的银行卡号，用于断言"""
        return self.get_text(PersonalCenterPageLocators.LATEST_CARD_NUMBER)